package smetana.util;

import java.util.Iterator;

/**
 *
 * @author dmitry.mamonov
 */
public class In {
    public static Iterable<Integer> range(final int from, final int to){
        return new Iterable<Integer>() {
            public Iterator<Integer> iterator() {
                return new Iterator<Integer>() {
                    int start = from;
                    public boolean hasNext() {
                        return start<to;
                    }

                    public Integer next() {
                        int result = start;
                        start++;
                        return result;
                    }

                    public void remove() {
                        throw new UnsupportedOperationException("Not supported.");
                    }
                };
            }
        };
    }
}
